package com.weidong.zk.service;

import com.weidong.zk.entity.User;
import com.weidong.zk.mapper.UserMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * @author weidong
 * @Email weidong2012@qq.com
 * @Date 2020/3/20 19:08
 * @Description DDD
 */
@Service
public class UserService {

    @Resource
    private UserMapper userMapper;

    public List<User> getAllUsers() {
        return userMapper.getAllUsers();
    }

    public int addUser(User user) {
        SimpleDateFormat form = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        user.setCreatedTime( form.format(new Date()) );
        return userMapper.addUser( user );
    }

    public int deleteUser(User user) {
        return userMapper.deleteUser( user );
    }

}
